data=acq.data(1:end,1:1:100);
m=repmat(mean(data)',[1 size(data,1)]);
m=m';
data=data-m;

data=MatchedFilter(data);
 ordem=400;
  b=fir1(ordem,[(acq.fc-1e6)/(acq.fs/2) (acq.fc+1e6)/(acq.fs/2)]);
     data=filter(b,1,data);
     dataf=data(ordem/2+1:end,:);
      Nl=39;
%      f_3dB=(0.85*acq.prf)/Nl;
%      vh_3dB=(1/cosd(acq.angulo))*(((acq.c/2)*f_3dB)/(acq.fc));
      dataf=RegLinear(data,Nl);
%dataf=dataf';
%% Feature 1 - Malene 2011 pg 50
Ns=20;Nl=100;
F1=zeros(1,size(data,1)/Ns);
for iseg=1:size(data,1)/Ns-1
    for l=1:Nl
        
        for k=1:Ns
            F1(iseg)=F1(iseg)+data(k+iseg*Ns,l).^2;
        end
    end
    F1(iseg)=F1(iseg)/ std(std(data((1:Ns)+(iseg-1)*Ns,1:Nl)));
end
figure(1);
subplot(2,1,1), plot(log10(F1)),subplot(2,1,2),plot(data(:,10).^2)
%% Feature 2 - Malene 2011 pg 50
Ns=50;Nl=39;
F2=zeros(1,size(dataf,1)/Ns);
for iseg=1:size(dataf,1)/Ns-1
    for l=1:Nl
        for k=1:Ns
            F2(iseg)=F2(iseg)+dataf(k+iseg*Ns,l).^2;
        end
    end
    F2(iseg)=F2(iseg)/ std(std(dataf((1:Ns)+(iseg-1)*Ns,1:Nl)));
end
figure(2);
subplot(2,1,1), plot(log10(F2)),subplot(2,1,2),plot(dataf(:,2).^2)
%% Feature 3 - Malene 2011 pg 50
Ns=50;Nl=39;
F3=zeros(1,size(data,1)/Ns);
for iseg=1:size(data,1)/Ns-1
    for k=1:Ns
        for l=1:Nl
            F3(iseg)=F3(iseg)+(data(k+iseg*Ns,l)-mean(data(k+iseg*Ns,1:Nl)))^2;
        end
        F3(iseg)=sqrt(F3(iseg)/(Nl-1));
    end
    F3(iseg)=F3(iseg)/std(std(data((1:Ns)+(iseg-1)*Ns,1:Nl)));
end
figure(3);
subplot(2,1,1), plot((F3)),subplot(2,1,2),plot(data(:,10).^2)
%% Feature 4 - Malene 2011 pg 50
Ns=50;Nl=39;
F4=zeros(1,size(dataf,1)/Ns);
for iseg=1:size(dataf,1)/Ns-1
    for k=1:Ns
        for l=1:Nl
            F4(iseg)=F4(iseg)+(dataf(k+iseg*Ns,l)-mean(dataf(k+iseg*Ns,1:Nl)))^2;
        end
        F4(iseg)=sqrt(F4(iseg)/(Nl-1));
    end
    F4(iseg)=F4(iseg)/std(std(dataf((1:Ns)+(iseg-1)*Ns,1:Nl)));
end
figure(4);
subplot(2,1,1), plot((F4)),subplot(2,1,2),plot(data(:,3).^1)
